def train(network,loss,epochs,learning_rate,X,Y):
    for epoch in range(epochs):
        error = 0
        for x, y in zip(X, Y):
            # forward
            output = x
            for layer in network:
                output = layer.forward(output)
            # error
            error += loss.loss(y, output)

            # backward
            grad = loss.loss_prime(y, output)
            for layer in reversed(network):
                grad = layer.backward(grad, learning_rate)

        error /= len(X)
        print('epoch: {}, error: {}'.format(epoch + 1, error))

def predict(network,X):
    for layer in network:
        X = layer.forward(X)
    print(X)